/*

 Copyright (c) 2008-2009 Fabrizio Pistonesi

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

 */

#ifndef PATCH_H_
#define PATCH_H_

#include<irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

class Patch
{
public:
	//FOR SKYBOX-SLIDE
	Patch(IrrlichtDevice *device, stringc image, bool visible=true, f32 x=-1, f32 y=-1, f32 w=0, f32 h=0, int face = 1, SColor color = SColor(255,255,255,255));
	//FOR SKYDOME
	Patch(IrrlichtDevice *device, stringc image, bool visible=true, f32 az=0, f32 el=0, f32 w=0, f32 h=0, SColor color = SColor(255,255,255,255));
	//FOR PANEL
	Patch(IrrlichtDevice *device, IGUIElement *parent , bool visible = true, stringc image = "missing.png", s32 x=0, s32 y=0, s32 w=-1, s32 h=-1, SColor color = SColor(255,255,255,255));
	virtual ~Patch();

	IrrlichtDevice	*Device;
	ISceneNode		*PatchCube;
	ITexture		*Texture;
	ISceneNode		*PatchRotation;
	IGUIImage		*PatchPanel;
	bool			 IsVisible;

	//serialize
	stringc                  Image;
	f32                      X, Y, W, H, Az, El;
	SColor                   Color;
	int                      Face;
	vector3df                Rotation;

	//BOX-SLIDE
	void move(f32 x, f32 y, f32 w=-1, f32 h=-1, int face=1);
	//DOME
	void move(f32 az, f32 el, f32 w=-1, f32 h=-1);
	//PANEL
	void move(s32 x, s32 y, s32 w=-1, s32 h=-1);

	void setColor(SColor color);
	void setVisible(bool visible);
	void setImage(const c8 *image);
	bool isVisible();
	void rotate(vector3df rotation);

	void serialize(IAttributes* attributes);
};

#endif /*PATCH_H_*/
